package com.baic.ibase.controller.api.v1;


import com.baic.ibase.models.dao.RolesPermissions;
import com.baic.ibase.models.req.common.ApiResponse;
import com.baic.ibase.models.req.common.PageResponse;
import com.baic.ibase.models.req.roles.CreateRolesPermissionsReq;
import com.baic.ibase.models.req.roles.QueryRolesPermissionsPage;
import com.baic.ibase.models.resp.QueryRolesPermissionsResp;
import com.baic.ibase.service.permissions.RolesPermissionService;
import com.baic.ibase.service.permissions.impl.RolesPermissionsServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/v1/rolesPermissions")
public class RolesPermissionsController {

    @Autowired
    private RolesPermissionService rolesPermissionsService;

    /**
     * @api {POST} /api/v1/rolesPermissions/ListRolesPermissions 查询角色权限列表
     * @apiVersion 1.0.0
     * @apiGroup RolesPermissionsController
     * @apiName ListRolesPermissions()
     * @apiParam (请求体) {Number} roleId
     * @apiParam (请求体) {Number} pageNum
     * @apiParam (请求体) {Number} pageSize
     * @apiParam (请求体) {String} sort
     * @apiParam (请求体) {String} order
     * @apiParam (请求体) {String} requestId
     * @apiParamExample 请求体示例
     * {"roleId":152,"requestId":"byqAQLyjCv","pageSize":3816,"sort":"N46x","pageNum":364,"order":"lIJY"}
     * @apiSuccess (响应结果) {Number} code
     * @apiSuccess (响应结果) {String} message
     * @apiSuccess (响应结果) {String} errors
     * @apiSuccess (响应结果) {String} traceId
     * @apiSuccess (响应结果) {Boolean} success
     * @apiSuccess (响应结果) {Object} data
     * @apiSuccess (响应结果) {String} data.requestId
     * @apiSuccess (响应结果) {Number} data.pageNum
     * @apiSuccess (响应结果) {Number} data.pageSize
     * @apiSuccess (响应结果) {Number} data.total
     * @apiSuccess (响应结果) {Number} data.pages
     * @apiSuccess (响应结果) {Array} data.data
     * @apiSuccess (响应结果) {Number} data.data.id
     * @apiSuccess (响应结果) {Number} data.data.roleId
     * @apiSuccess (响应结果) {Number} data.data.permissionId
     * @apiSuccess (响应结果) {String} data.data.permissionCode
     * @apiSuccess (响应结果) {String} data.data.permissionName
     * @apiSuccess (响应结果) {String} data.data.permissionDesc
     * @apiSuccessExample 响应结果示例
     * {"traceId":"vh","code":8001,"data":{"total":9015,"pages":2672,"data":[{"permissionDesc":"D","permissionId":3527,"roleId":139,"id":9189,"permissionCode":"xoTJwo","permissionName":"ruBH"}],"requestId":"6","pageSize":3324,"pageNum":7432},"success":true,"message":"4B","errors":"RMpD"}
     */
    @RequestMapping("/ListRolesPermissions")
    public ApiResponse<PageResponse<QueryRolesPermissionsResp>> ListRolesPermissions(@RequestBody QueryRolesPermissionsPage req)
    {
        log.info("ListRolesPermissions req:{}", req);
        return rolesPermissionsService.listRolesPermissions(req);
    }


}
